package yourapp.expense.entity;

import java.math.BigDecimal;
import java.util.Date;

public class Expense {
  private int expenseId;
  private BigDecimal amount;
  private Date expenseDate;
  private String description;

  // 关联的三个分类对象（注意：可为null）
  private PaymentAppCategory paymentAppCategory;    // 支付软件分类（可为null）
  private ShoppingAppCategory shoppingAppCategory;  // 购物软件分类（可为null）
  private PurposeCategory purposeCategory;          // 用途分类（必填）
  //新增代码
  // 新增字段
  private String paymentAppName;
  private String shoppingAppName;
  private String purposeCategoryName;

  // 新增 getter 和 setter 方法
  public String getPaymentAppName() { return paymentAppName; }
  public void setPaymentAppName(String paymentAppName) { this.paymentAppName = paymentAppName; }

  public String getShoppingAppName() { return shoppingAppName; }
  public void setShoppingAppName(String shoppingAppName) { this.shoppingAppName = shoppingAppName; }

  public String getPurposeCategoryName() { return purposeCategoryName; }
  public void setPurposeCategoryName(String purposeCategoryName) { this.purposeCategoryName = purposeCategoryName; }

  // 构造方法
  public Expense() {}

  public Expense(BigDecimal amount, Date expenseDate, String description,
                 PaymentAppCategory paymentAppCategory, ShoppingAppCategory shoppingAppCategory,
                 PurposeCategory purposeCategory) {
    this.amount = amount;
    this.expenseDate = expenseDate;
    this.description = description;
    this.paymentAppCategory = paymentAppCategory;
    this.shoppingAppCategory = shoppingAppCategory;
    this.purposeCategory = purposeCategory;
  }

  // Getter和Setter方法
  public int getExpenseId() { return expenseId; }
  public void setExpenseId(int expenseId) { this.expenseId = expenseId; }

  public BigDecimal getAmount() { return amount; }
  public void setAmount(BigDecimal amount) { this.amount = amount; }

  public Date getExpenseDate() { return expenseDate; }
  public void setExpenseDate(Date expenseDate) { this.expenseDate = expenseDate; }

  public String getDescription() { return description; }
  public void setDescription(String description) { this.description = description; }

  public PaymentAppCategory getPaymentAppCategory() { return paymentAppCategory; }
  public void setPaymentAppCategory(PaymentAppCategory paymentAppCategory) {
    this.paymentAppCategory = paymentAppCategory;
  }

  public ShoppingAppCategory getShoppingAppCategory() { return shoppingAppCategory; }
  public void setShoppingAppCategory(ShoppingAppCategory shoppingAppCategory) {
    this.shoppingAppCategory = shoppingAppCategory;
  }

  public PurposeCategory getPurposeCategory() { return purposeCategory; }

  public void setPurposeCategory(PurposeCategory purposeCategory) {
    this.purposeCategory = purposeCategory;
  }

  @Override
  public String toString() {
    return String.format("支出ID: %d, 金额: %.2f, 日期: %s, 用途: %s, 支付方式: %s, 购物平台: %s, 描述: %s",
        expenseId, amount, expenseDate,
        purposeCategory != null ? purposeCategory.getName() : "未知",
        paymentAppCategory != null ? paymentAppCategory.getName() : "无",
        shoppingAppCategory != null ? shoppingAppCategory.getName() : "无",
        description != null ? description : "无");
  }
}